package com.dmooo.yxmmerchant.view.presenter;

import android.content.Context;

import com.common.mvpbase.BasePresenter;
import com.common.net.listener.HttpOnNextListener;
import com.dmooo.yxmmerchant.view.contract.ChangePhonePwdContract;
import com.dmooo.yxmmerchant.view.model.ChangePhonePwdModel;

public class ChangePhonePwdPreseter extends BasePresenter<ChangePhonePwdContract.ChangeView> implements ChangePhonePwdContract.ChangePtr {
    private ChangePhonePwdModel model;
    public ChangePhonePwdPreseter(ChangePhonePwdContract.ChangeView mView, Context context) {
        super(mView);
        model=new ChangePhonePwdModel(context);
    }

    @Override
    public void sendOldPhone(String token) {
        model.sendOldPhone(token, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.sendOldPhoneSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void sendNewPhone(String phone) {
        model.sendNewPhone(phone, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.sendNewPhoneSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void changePhone(String token, String old_code, String phone, String code) {
        model.changePhone(token, old_code, phone, code, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.changePhoneSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void changePwd(String token, String oldPwd, String newPwd, String newPwd2) {
        model.changePwd(token, oldPwd, newPwd, newPwd2, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.changePwdSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void getResetPhoneCode(String phone) {
        model.getResetPhoneCode(phone, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.sendNewPhoneSuccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }

    @Override
    public void resetPhonePwd(String phone, String code, String pwd) {
        model.resetPhonePwd(phone,code,pwd, new HttpOnNextListener() {
            @Override
            public void onNext(Object o) {
                mView.resetSccess();
            }

            @Override
            public void onFail(Object o) {
                mView.errorMsg(o.toString());
            }

            @Override
            public void onStart() {

            }

            @Override
            public void onComplete() {

            }
        });
    }
}
